﻿/*
版权所有：版权所有(C) 2011，刘建新
文件编号：M01_LeaveMsgMgnt.cs
文件名称：LeaveMsgMgnt.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2011-01-06
作　　者：
内容摘要：表[Leave_msg_Mgnt]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：LeaveMsgMgnt
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class LeaveMsgMgnt : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is LeaveMsgMgnt)
				{
					if (obj == this)
						return true;
					LeaveMsgMgnt castObj = (LeaveMsgMgnt)obj; 
					
					if (!this.m_MsgId.Equals(castObj.MsgId))
						return false;
						
					if (!this.m_KeyType.Equals(castObj.KeyType))
						return false;
						
					if (!this.m_KeyValue.Equals(castObj.KeyValue))
						return false;
						
					if (!this.m_MsgContent.Equals(castObj.MsgContent))
						return false;
						
					if (!this.m_MsgTitle.Equals(castObj.MsgTitle))
						return false;
						
					if (!this.m_Ip.Equals(castObj.Ip))
						return false;
						
					if (!this.m_Status.Equals(castObj.Status))
						return false;
						
					if (!this.m_ParentId.Equals(castObj.ParentId))
						return false;
						
					if (!this.m_Rating.Equals(castObj.Rating))
						return false;
						
					if (!this.m_CreateDate.Equals(castObj.CreateDate))
						return false;
						
					if (!this.m_CreateBy.Equals(castObj.CreateBy))
						return false;
						
					if (!this.m_LastUpdateDate.Equals(castObj.LastUpdateDate))
						return false;
						
					if (!this.m_LastUpdateBy.Equals(castObj.LastUpdateBy))
						return false;
						
					if (!this.m_ReceiverId.Equals(castObj.ReceiverId))
						return false;
						
					if (!this.m_IsViewed.Equals(castObj.IsViewed))
						return false;
						
					if (!this.m_Havenews.Equals(castObj.Havenews))
						return false;
						
					if (!this.m_Mainid.Equals(castObj.Mainid))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_MsgId != null)
					{
						hash = hash ^ m_MsgId.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_KeyType != null)
					{
						hash = hash ^ m_KeyType.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_KeyValue != null)
					{
						hash = hash ^ m_KeyValue.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_MsgContent != null)
					{
						hash = hash ^ m_MsgContent.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_MsgTitle != null)
					{
						hash = hash ^ m_MsgTitle.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Ip != null)
					{
						hash = hash ^ m_Ip.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Status != null)
					{
						hash = hash ^ m_Status.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_ParentId != null)
					{
						hash = hash ^ m_ParentId.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Rating != null)
					{
						hash = hash ^ m_Rating.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_CreateDate != null)
					{
						hash = hash ^ m_CreateDate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_CreateBy != null)
					{
						hash = hash ^ m_CreateBy.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LastUpdateDate != null)
					{
						hash = hash ^ m_LastUpdateDate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LastUpdateBy != null)
					{
						hash = hash ^ m_LastUpdateBy.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_ReceiverId != null)
					{
						hash = hash ^ m_ReceiverId.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_IsViewed != null)
					{
						hash = hash ^ m_IsViewed.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Havenews != null)
					{
						hash = hash ^ m_Havenews.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Mainid != null)
					{
						hash = hash ^ m_Mainid.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public LeaveMsgMgnt()
			{
				MarkNew();
			}						
			
			public LeaveMsgMgnt GetOldValue()
			{
				return OldValue as LeaveMsgMgnt;
			}
		
		#region MsgId属性
			private int m_MsgId = 0;
			/// <summary>
			/// 属性名称： MsgId
			/// 内容摘要： DB列名：Msg_ID[]
			///            DB类型：int
			/// </summary>
			public int MsgId
			{
				get
					{
						return m_MsgId;
					}
				set
					{
						if (m_MsgId as object == null || !m_MsgId.Equals(value))
						{
							m_MsgId = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region KeyType属性
			private string m_KeyType = String.Empty;
			/// <summary>
			/// 属性名称： KeyType
			/// 内容摘要： DB列名：Key_Type[]
			///            DB类型：string
			/// </summary>
			public string KeyType
			{
				get
					{
						return m_KeyType;
					}
				set
					{
						if (m_KeyType as object == null || !m_KeyType.Equals(value))
						{
							m_KeyType = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region KeyValue属性
			private string m_KeyValue = String.Empty;
			/// <summary>
			/// 属性名称： KeyValue
			/// 内容摘要： DB列名：Key_Value[]
			///            DB类型：string
			/// </summary>
			public string KeyValue
			{
				get
					{
						return m_KeyValue;
					}
				set
					{
						if (m_KeyValue as object == null || !m_KeyValue.Equals(value))
						{
							m_KeyValue = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region MsgContent属性
			private string m_MsgContent = String.Empty;
			/// <summary>
			/// 属性名称： MsgContent
			/// 内容摘要： DB列名：Msg_Content[]
			///            DB类型：string
			/// </summary>
			public string MsgContent
			{
				get
					{
						return m_MsgContent;
					}
				set
					{
						if (m_MsgContent as object == null || !m_MsgContent.Equals(value))
						{
							m_MsgContent = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region MsgTitle属性
			private string m_MsgTitle = String.Empty;
			/// <summary>
			/// 属性名称： MsgTitle
			/// 内容摘要： DB列名：Msg_Title[]
			///            DB类型：string
			/// </summary>
			public string MsgTitle
			{
				get
					{
						return m_MsgTitle;
					}
				set
					{
						if (m_MsgTitle as object == null || !m_MsgTitle.Equals(value))
						{
							m_MsgTitle = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Ip属性
			private string m_Ip = String.Empty;
			/// <summary>
			/// 属性名称： Ip
			/// 内容摘要： DB列名：IP[]
			///            DB类型：string
			/// </summary>
			public string Ip
			{
				get
					{
						return m_Ip;
					}
				set
					{
						if (m_Ip as object == null || !m_Ip.Equals(value))
						{
							m_Ip = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Status属性
			private int m_Status = 0;
			/// <summary>
			/// 属性名称： Status
			/// 内容摘要： DB列名：Status[]
			///            DB类型：int
			/// </summary>
			public int Status
			{
				get
					{
						return m_Status;
					}
				set
					{
						if (m_Status as object == null || !m_Status.Equals(value))
						{
							m_Status = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region ParentId属性
			private int m_ParentId = 0;
			/// <summary>
			/// 属性名称： ParentId
			/// 内容摘要： DB列名：Parent_ID[]
			///            DB类型：int
			/// </summary>
			public int ParentId
			{
				get
					{
						return m_ParentId;
					}
				set
					{
						if (m_ParentId as object == null || !m_ParentId.Equals(value))
						{
							m_ParentId = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Rating属性
			private int m_Rating = 0;
			/// <summary>
			/// 属性名称： Rating
			/// 内容摘要： DB列名：Rating[]
			///            DB类型：int
			/// </summary>
			public int Rating
			{
				get
					{
						return m_Rating;
					}
				set
					{
						if (m_Rating as object == null || !m_Rating.Equals(value))
						{
							m_Rating = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region CreateDate属性
			private DateTime m_CreateDate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： CreateDate
			/// 内容摘要： DB列名：Create_Date[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime CreateDate
			{
				get
					{
						return DateTime.Parse(m_CreateDate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_CreateDate as object == null || !m_CreateDate.Equals(value))
						{
							m_CreateDate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region CreateBy属性
			private string m_CreateBy = String.Empty;
			/// <summary>
			/// 属性名称： CreateBy
			/// 内容摘要： DB列名：Create_By[]
			///            DB类型：string
			/// </summary>
			public string CreateBy
			{
				get
					{
						return m_CreateBy;
					}
				set
					{
						if (m_CreateBy as object == null || !m_CreateBy.Equals(value))
						{
							m_CreateBy = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LastUpdateDate属性
			private DateTime m_LastUpdateDate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： LastUpdateDate
			/// 内容摘要： DB列名：Last_update_Date[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime LastUpdateDate
			{
				get
					{
						return DateTime.Parse(m_LastUpdateDate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_LastUpdateDate as object == null || !m_LastUpdateDate.Equals(value))
						{
							m_LastUpdateDate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LastUpdateBy属性
			private string m_LastUpdateBy = String.Empty;
			/// <summary>
			/// 属性名称： LastUpdateBy
			/// 内容摘要： DB列名：Last_update_By[]
			///            DB类型：string
			/// </summary>
			public string LastUpdateBy
			{
				get
					{
						return m_LastUpdateBy;
					}
				set
					{
						if (m_LastUpdateBy as object == null || !m_LastUpdateBy.Equals(value))
						{
							m_LastUpdateBy = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region ReceiverId属性
			private string m_ReceiverId = String.Empty;
			/// <summary>
			/// 属性名称： ReceiverId
			/// 内容摘要： DB列名：receiver_id[]
			///            DB类型：string
			/// </summary>
			public string ReceiverId
			{
				get
					{
						return m_ReceiverId;
					}
				set
					{
						if (m_ReceiverId as object == null || !m_ReceiverId.Equals(value))
						{
							m_ReceiverId = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region IsViewed属性
			private int m_IsViewed = 0;
			/// <summary>
			/// 属性名称： IsViewed
			/// 内容摘要： DB列名：is_viewed[]
			///            DB类型：int
			/// </summary>
			public int IsViewed
			{
				get
					{
						return m_IsViewed;
					}
				set
					{
						if (m_IsViewed as object == null || !m_IsViewed.Equals(value))
						{
							m_IsViewed = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Havenews属性
			private int m_Havenews = 0;
			/// <summary>
			/// 属性名称： Havenews
			/// 内容摘要： DB列名：HaveNews[]
			///            DB类型：int
			/// </summary>
			public int Havenews
			{
				get
					{
						return m_Havenews;
					}
				set
					{
						if (m_Havenews as object == null || !m_Havenews.Equals(value))
						{
							m_Havenews = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Mainid属性
			private int m_Mainid = 0;
			/// <summary>
			/// 属性名称： Mainid
			/// 内容摘要： DB列名：MainId[]
			///            DB类型：int
			/// </summary>
			public int Mainid
			{
				get
					{
						return m_Mainid;
					}
				set
					{
						if (m_Mainid as object == null || !m_Mainid.Equals(value))
						{
							m_Mainid = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("Msg_ID",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Key_Type",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Key_Value",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Msg_Content",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Msg_Title",typeof(string)));
					dtResult.Columns.Add(new DataColumn("IP",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Status",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Parent_ID",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Rating",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Create_Date",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Create_By",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Last_update_Date",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Last_update_By",typeof(string)));
					dtResult.Columns.Add(new DataColumn("receiver_id",typeof(string)));
					dtResult.Columns.Add(new DataColumn("is_viewed",typeof(int)));
					dtResult.Columns.Add(new DataColumn("HaveNews",typeof(int)));
					dtResult.Columns.Add(new DataColumn("MainId",typeof(int)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("MsgId",typeof(int)));
					dtResult.Columns.Add(new DataColumn("KeyType",typeof(string)));
					dtResult.Columns.Add(new DataColumn("KeyValue",typeof(string)));
					dtResult.Columns.Add(new DataColumn("MsgContent",typeof(string)));
					dtResult.Columns.Add(new DataColumn("MsgTitle",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Ip",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Status",typeof(int)));
					dtResult.Columns.Add(new DataColumn("ParentId",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Rating",typeof(int)));
					dtResult.Columns.Add(new DataColumn("CreateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("CreateBy",typeof(string)));
					dtResult.Columns.Add(new DataColumn("LastUpdateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("LastUpdateBy",typeof(string)));
					dtResult.Columns.Add(new DataColumn("ReceiverId",typeof(string)));
					dtResult.Columns.Add(new DataColumn("IsViewed",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Havenews",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Mainid",typeof(int)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["Msg_ID"] = this.MsgId;
					dr["Key_Type"] = this.KeyType;
					dr["Key_Value"] = this.KeyValue;
					dr["Msg_Content"] = this.MsgContent;
					dr["Msg_Title"] = this.MsgTitle;
					dr["IP"] = this.Ip;
					dr["Status"] = this.Status;
					dr["Parent_ID"] = this.ParentId;
					dr["Rating"] = this.Rating;
					dr["Create_Date"] = this.CreateDate;
					dr["Create_By"] = this.CreateBy;
					dr["Last_update_Date"] = this.LastUpdateDate;
					dr["Last_update_By"] = this.LastUpdateBy;
					dr["receiver_id"] = this.ReceiverId;
					dr["is_viewed"] = this.IsViewed;
					dr["HaveNews"] = this.Havenews;
					dr["MainId"] = this.Mainid;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["MsgId"] = this.MsgId;
					dr["KeyType"] = this.KeyType;
					dr["KeyValue"] = this.KeyValue;
					dr["MsgContent"] = this.MsgContent;
					dr["MsgTitle"] = this.MsgTitle;
					dr["Ip"] = this.Ip;
					dr["Status"] = this.Status;
					dr["ParentId"] = this.ParentId;
					dr["Rating"] = this.Rating;
					dr["CreateDate"] = this.CreateDate;
					dr["CreateBy"] = this.CreateBy;
					dr["LastUpdateDate"] = this.LastUpdateDate;
					dr["LastUpdateBy"] = this.LastUpdateBy;
					dr["ReceiverId"] = this.ReceiverId;
					dr["IsViewed"] = this.IsViewed;
					dr["Havenews"] = this.Havenews;
					dr["Mainid"] = this.Mainid;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成LeaveMsgMgnt对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>LeaveMsgMgnt对象</returns>
			public static LeaveMsgMgnt Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				LeaveMsgMgnt obj = new LeaveMsgMgnt();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.MsgId = (dr["Msg_ID"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Msg_ID"],typeof(int));
					obj.KeyType = (dr["Key_Type"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Key_Type"],typeof(string));
					obj.KeyValue = (dr["Key_Value"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Key_Value"],typeof(string));
					obj.MsgContent = (dr["Msg_Content"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Msg_Content"],typeof(string));
					obj.MsgTitle = (dr["Msg_Title"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Msg_Title"],typeof(string));
					obj.Ip = (dr["IP"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["IP"],typeof(string));
					obj.Status = (dr["Status"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Status"],typeof(int));
					obj.ParentId = (dr["Parent_ID"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Parent_ID"],typeof(int));
					obj.Rating = (dr["Rating"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Rating"],typeof(int));
					obj.CreateDate = (dr["Create_Date"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Create_Date"],typeof(DateTime));
					obj.CreateBy = (dr["Create_By"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Create_By"],typeof(string));
					obj.LastUpdateDate = (dr["Last_update_Date"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Last_update_Date"],typeof(DateTime));
					obj.LastUpdateBy = (dr["Last_update_By"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Last_update_By"],typeof(string));
					obj.ReceiverId = (dr["receiver_id"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["receiver_id"],typeof(string));
					obj.IsViewed = (dr["is_viewed"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["is_viewed"],typeof(int));
					obj.Havenews = (dr["HaveNews"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["HaveNews"],typeof(int));
					obj.Mainid = (dr["MainId"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["MainId"],typeof(int));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.MsgId = (dr["MsgId"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["MsgId"],typeof(int));
					obj.KeyType = (dr["KeyType"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["KeyType"],typeof(string));
					obj.KeyValue = (dr["KeyValue"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["KeyValue"],typeof(string));
					obj.MsgContent = (dr["MsgContent"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["MsgContent"],typeof(string));
					obj.MsgTitle = (dr["MsgTitle"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["MsgTitle"],typeof(string));
					obj.Ip = (dr["Ip"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Ip"],typeof(string));
					obj.Status = (dr["Status"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Status"],typeof(int));
					obj.ParentId = (dr["ParentId"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["ParentId"],typeof(int));
					obj.Rating = (dr["Rating"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Rating"],typeof(int));
					obj.CreateDate = (dr["CreateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDate"],typeof(DateTime));
					obj.CreateBy = (dr["CreateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CreateBy"],typeof(string));
					obj.LastUpdateDate = (dr["LastUpdateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["LastUpdateDate"],typeof(DateTime));
					obj.LastUpdateBy = (dr["LastUpdateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["LastUpdateBy"],typeof(string));
					obj.ReceiverId = (dr["ReceiverId"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["ReceiverId"],typeof(string));
					obj.IsViewed = (dr["IsViewed"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["IsViewed"],typeof(int));
					obj.Havenews = (dr["Havenews"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Havenews"],typeof(int));
					obj.Mainid = (dr["Mainid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Mainid"],typeof(int));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成LeaveMsgMgnt对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>LeaveMsgMgnt对象</returns>
			public static LeaveMsgMgnt Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的LeaveMsgMgnt对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>LeaveMsgMgnt对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的LeaveMsgMgnt对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>LeaveMsgMgnt对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的LeaveMsgMgnt对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">LeaveMsgMgnt对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(LeaveMsgMgnt obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的LeaveMsgMgnt对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">LeaveMsgMgnt对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			LeaveMsgMgnt old = this.OldValue as LeaveMsgMgnt;
			if (old != null)
			{
					this.MsgId = old.MsgId;
					this.KeyType = old.KeyType;
					this.KeyValue = old.KeyValue;
					this.MsgContent = old.MsgContent;
					this.MsgTitle = old.MsgTitle;
					this.Ip = old.Ip;
					this.Status = old.Status;
					this.ParentId = old.ParentId;
					this.Rating = old.Rating;
					this.CreateDate = old.CreateDate;
					this.CreateBy = old.CreateBy;
					this.LastUpdateDate = old.LastUpdateDate;
					this.LastUpdateBy = old.LastUpdateBy;
					this.ReceiverId = old.ReceiverId;
					this.IsViewed = old.IsViewed;
					this.Havenews = old.Havenews;
					this.Mainid = old.Mainid;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region LeaveMsgMgnt实体的内部Key类
			/// <summary>
			/// LeaveMsgMgnt实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_MsgId;
				public int MsgId
				{
 					get 
					{ 
						 return m_MsgId; 
					}
					set 
					{ 
						m_MsgId = value;
					}
				}
		
				public Key(int pMsgId)
				{
					m_MsgId=pMsgId;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体LeaveMsgMgnt的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(MsgId);				
			}
			
				
		#endregion
	}
}
